#!/bin/bash
echo "Running acopt tests..."

testnum=0


# TEST 1
testnum=$(($testnum+1))
rm -f msweb-out1.ac
#../../../libra-tk-old/bin/acopt -i baudio-e100k.ac -o baudio-test1.ac -tb baudio.xmod -ev baudio1.tev -gibbs -gspeed fast > baudio-test1.log
../../bin/acopt -m msweb-ac.ac -o msweb-out1.ac -ma msweb-cl.xmod -ev msweb.ev -gibbs -gspeed fast -seed 1 -log msweb-out1.log
./diffr msweb-test1.ac msweb-out1.ac > /dev/null
if [ $? -ne 0 ]; then echo "Test $testnum: FAILED"; else echo "Test $testnum: Success"; fi

# TEST 2
testnum=$(($testnum+1))
rm -f msweb-out2.ac
#../../../libra-tk-old/bin/acopt -i msweb-e100k.ac -o msweb-test2.ac -tb msweb.xmod -ev msweb1.tev -maxiter 5 > msweb-test2.log
../../bin/acopt -m msweb-ac.ac -o msweb-out2.ac -ma ../../doc/tutorial/msweb.xmod -ev msweb.ev -maxiter 1 -log msweb-out2.log
./diffr msweb-test2.ac msweb-out2.ac > /dev/null
if [ $? -ne 0 ]; then echo "Test $testnum: FAILED"; else echo "Test $testnum: Success"; fi

# TEST 3
testnum=$(($testnum+1))
rm -f msweb-out3.ac
../../bin/mconvert -m msweb-cl.xmod -o msweb-cl.mn -ev msweb.ev 
../../bin/acopt -m msweb-ac.ac -o msweb-out3.ac -ev msweb.ev -ma msweb-cl.mn -gibbs -gspeed fast -seed 1 -log msweb-out3.log
./diffr msweb-test3.ac msweb-out3.ac > /dev/null
if [ $? -ne 0 ]; then echo "Test $testnum: FAILED"; else echo "Test $testnum: Success"; fi

# TEST 4
testnum=$(($testnum+1))
rm -f msweb-out4.ac
../../bin/mconvert -m ../../doc/tutorial/msweb.xmod -o msweb.mn -ev msweb.ev 
../../bin/acopt -m msweb-ac.ac -o msweb-out4.ac -ev msweb.ev -ma msweb.mn -ev msweb.ev -maxiter 1 -log msweb-out4.log
./diffr msweb-test4.ac msweb-out4.ac > /dev/null
if [ $? -ne 0 ]; then echo "Test $testnum: FAILED"; else echo "Test $testnum: Success"; fi

#testnum=$(($testnum+1))
#rm -f msweb-out1.ac
#../../../libra-tk-old/bin/acopt -i baudio-e100k.ac -o baudio-test1.ac -tb baudio.xmod -ev baudio1.tev -gibbs -gspeed fast > baudio-test1.log
#../../bin/acopt -c msweb-ac.ac -o msweb-out1.ac -b msweb-cl.xmod -ev msweb.ev -gibbs -gspeed medium -seed 1 -log msweb-out1.log
#./diffr msweb-test1.ac msweb-out1.ac > /dev/null
#if [ $? -ne 0 ]; then echo "Test $testnum: FAILED"; else echo "Test $testnum: Success"; fi

# TEST 5
#testnum=$(($testnum+1))
#rm -f baudio-out1.ac
##../../../libra-tk-old/bin/acopt -i baudio-e100k.ac -o baudio-test1.ac -tb baudio.xmod -ev baudio1.tev -gibbs -gspeed fast > baudio-test1.log
#../../bin/acopt -c baudio-e100k.ac -o baudio-out1.ac -m baudio.xmod -ev baudio1.tev -gibbs -gspeed fast -seed 1 -log baudio-out1.log
#./diffr baudio-test1.ac baudio-out1.ac > /dev/null
#if [ $? -ne 0 ]; then echo "Test $testnum: FAILED"; else echo "Test $testnum: Success"; fi

# TEST 6
#testnum=$(($testnum+1))
#rm -f baudio-out2.ac
##../../../libra-tk-old/bin/acopt -i baudio-e100k.ac -o baudio-test2.ac -tb baudio.xmod -ev baudio1.tev -maxiter 5 > baudio-test2.log
#../../bin/acopt -c baudio-e100k.ac -o baudio-out2.ac -m baudio.xmod -ev baudio1.tev -maxiter 1 -log baudio-out2.log
#./diffr baudio-test2.ac baudio-out2.ac > /dev/null
#if [ $? -ne 0 ]; then echo "Test $testnum: FAILED"; else echo "Test $testnum: Success"; fi


rm *.ac-r
